package com.share.user.api;

import com.share.common.core.domain.R;
import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.common.security.annotation.InnerAuth;
import com.share.common.security.annotation.RequiresLogin;
import com.share.user.api.domain.UpdateUserLogin;
import com.share.user.api.domain.UserInfo;
import com.share.user.service.IUserInfoService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 会员用户远程调用接口管理
 *
 * @author zxl
 * @date 2025年03月25日 17:40
 */

@RestController
@RequestMapping("/userInfo")
public class UserInfoApiController extends BaseController {
    @Autowired
    IUserInfoService userInfoService;

    @Operation(summary = "小程序授权登录")
//    @InnerAuth
    @GetMapping("/wxLogin/{code}")
    public R<UserInfo> wxLogin(@PathVariable String code) {
        return R.ok(userInfoService.wxLogin(code));
    }

    @Operation(summary = "更新用户登录信息")
    @InnerAuth
    @PutMapping("/updateUserLogin")
    public R<Boolean> updateUserLogin(@RequestBody UpdateUserLogin updateUserLogin) {
        return R.ok(userInfoService.updateUserLogin(updateUserLogin));
    }

    /**
     * 免押金接口：模拟微信支付分达到免押金的情况，如果deposit_status状态不是1免押金，则改成1免押金
     */
    @Operation(summary = "是否免押金")
    @RequiresLogin
    @GetMapping("/isFreeDeposit")
    public AjaxResult isFreeDeposit() {
        return AjaxResult.success(userInfoService.isFreeDeposit());
    }


}
